#include<iostream>
using namespace std;
int dfs(int arr[4][4], int idx, int x, int y) {
	if (x < 0 || y < 0 || x >= 4 || y >= 4) {
		return 0;
	}
	if (arr[y][x]) {
		return 0;
	}
	if (idx >= 15) {
		return 1;
	}
	int count = 0;
	arr[y][x] = true;
	count += dfs(arr, idx + 1, x + 1, y);
	count += dfs(arr, idx + 1, x, y + 1); 
	count += dfs(arr, idx + 1, x - 1, y); 
	count += dfs(arr, idx + 1, x, y - 1);
	arr[y][x] = false;
	return count;
}
int main() {
	int arr[4][4];
	int count = 0;
	int i;
	for (i = 0; i < 16; i++) {
		count += dfs(arr, 0, i % 4, i / 4);
	}
	cout << count << endl;
	return 0;
}
